
pkgname=pacman
pkgver=5.1.0
pkgrel=2
pkgdesc="A library-based package manager with dependency support"
arch=('x86_64')
url="http://www.archlinux.org/pacman/"
license=('GPL')
groups=('base')
depends=('bash' 'glibc' 'libarchive' 'curl' 'gpgme' 'pacman-mirrorlist')
makedepends=('asciidoc')
checkdepends=('python2' 'fakechroot')
backup=(etc/pacman.conf etc/makepkg.conf)
options=('!libtool')
#install=pacman.install
source=("https://sources.archlinux.org/other/pacman/${pkgname}-${pkgver}.tar.gz"
        'pacman.conf'
        'makepkg.conf'
        'file5.33.patch')
md5sums=('7b0460d449323eb3097ab39913d2668b'
         '5600ceea45ce0de5262a0c37f42ea28b'
         'cf7f1e8b63baeab69a20264820bed9cc'
         '9eb04bd318524d87f22c8ce7fa47693f')

build() {
  cd ${pkgname}-${pkgver}
  #patch -p1 -i ${srcdir}/file5.33.patch
  
  ./configure --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --enable-doc \
    --with-scriptlet-shell=/bin/bash \
    --with-ldconfig=/bin/ldconfig
  make V=1
}

check() {
  make -C ${pkgname}-${pkgver} check
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install

  mkdir -p ${pkgdir}/etc
  install -m644 $srcdir/pacman.conf ${pkgdir}/etc/pacman.conf
  install -m644 $srcdir/makepkg.conf ${pkgdir}/etc/

  # completion files
  install -Dm644 scripts/completion/bash_completion ${pkgdir}/usr/share/bash-completion/completions/pacman
  install -Dm644 scripts/completion/zsh_completion ${pkgdir}/usr/share/zsh/site-functions/_pacman
  
  for f in makepkg pacman-key; do
    ln -s pacman "${pkgdir}/usr/share/bash-completion/completions/$f"
  done
}

